<template>
  <a-drawer v-model:visible="visible" title="压力测试报告详情" :width="width >= 580 ? 580 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="所属报告ID">{{ dataDetail?.reportId }}</a-descriptions-item>
      <a-descriptions-item label="断言信息">{{ dataDetail?.assertInfo }}</a-descriptions-item>
      <a-descriptions-item label="错误请求数">{{ dataDetail?.errorCount }}</a-descriptions-item>
      <a-descriptions-item label="错误百分比">{{ dataDetail?.errorPercentage }}</a-descriptions-item>
      <a-descriptions-item label="最大响应时间">{{ dataDetail?.maxTime }}</a-descriptions-item>
      <a-descriptions-item label="平均响应时间">{{ dataDetail?.meanTime }}</a-descriptions-item>
      <a-descriptions-item label="最小响应时间">{{ dataDetail?.minTime }}</a-descriptions-item>
      <a-descriptions-item label="每秒接收KB">{{ dataDetail?.receiveKBPerSecond }}</a-descriptions-item>
      <a-descriptions-item label="每秒发送KB">{{ dataDetail?.sentKBPerSecond }}</a-descriptions-item>
      <a-descriptions-item label="请求路径和参数">{{ dataDetail?.requestLocation }}</a-descriptions-item>
      <a-descriptions-item label="请求头">{{ dataDetail?.requestHeader }}</a-descriptions-item>
      <a-descriptions-item label="请求体">{{ dataDetail?.requestBody }}</a-descriptions-item>
      <a-descriptions-item label="每秒请求速率">{{ dataDetail?.requestRate }}</a-descriptions-item>
      <a-descriptions-item label="响应码">{{ dataDetail?.responseCode }}</a-descriptions-item>
      <a-descriptions-item label="响应体">{{ dataDetail?.responseData }}</a-descriptions-item>
      <a-descriptions-item label="响应头">{{ dataDetail?.responseHeader }}</a-descriptions-item>
      <a-descriptions-item label="采样次数编号">{{ dataDetail?.samplerCount }}</a-descriptions-item>
      <a-descriptions-item label="请求名称">{{ dataDetail?.samplerLabel }}</a-descriptions-item>
      <a-descriptions-item label="请求时间戳">{{ dataDetail?.sampleTime }}</a-descriptions-item>
      <a-descriptions-item label="乐观锁">{{ dataDetail?.version }}</a-descriptions-item>
      <a-descriptions-item label="业务状态">{{ dataDetail?.status }}</a-descriptions-item>
      <a-descriptions-item label="逻辑删除 1: 已删除， 0: 未删除">{{ dataDetail?.isDeleted }}</a-descriptions-item>
      <a-descriptions-item label="创建者">{{ dataDetail?.createdBy }}</a-descriptions-item>
      <a-descriptions-item label="更新者">{{ dataDetail?.updatedBy }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createdAt }}</a-descriptions-item>
      <a-descriptions-item label="更新时间">{{ dataDetail?.updatedAt }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script lang="ts" setup>
import { useWindowSize } from '@vueuse/core'
import { type ReportDetailStressDetailResp, getReportDetailStress } from '@/apis'

const { width } = useWindowSize()

const visible = ref(false)
const dataId = ref('')
const dataDetail = ref<ReportDetailStressDetailResp>()
// 查询详情
const getDataDetail = async () => {
  const res = await getReportDetailStress(dataId.value)
  dataDetail.value = res.data
}

// 打开详情
const onDetail = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onDetail })
</script>

<style lang="scss" scoped></style>
